/*
 * @lc app=leetcode.cn id=26 lang=swift
 *
 * [26] 删除排序数组中的重复项
 */

// @lc code=start
class Solution {
    func removeDuplicates(_ nums: inout [Int]) -> Int {
        if nums.count < 2 { return nums.count }
        var left = 1, right = 1
        var temp = nums[0]
        while right < nums.count {
            if nums[right] == temp {
                right += 1
                continue
            }
            if left != right {
                nums[left] = nums[right]
            }
            temp = nums[right]
            left += 1
            right += 1
        }
        return left
    }
}
// @lc code=end

